<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字符串形式ref</title>

</head>
<body>
<div id="test"></div>
</body>
<script src="../js/react.development.js"></script>
<script src="../js/react-dom.development.js"></script>
<!--将jsx转为js-->
<script src="../js/babel.min.js"></script>
<script src="../js/prop-types.js"></script>
<!--babel  由babel转换jsx-->
<script type="text/babel">
    class Demo extends React.Component {
        showData = () => {
            alert(this.refs['input1'].value)
        }
        showDataBlur = () => {
            alert(this.refs['input2'].value)
        }
        render() {
            return (
                <div>
                    <input ref="input1" type="text" placeholder="点击按钮提示数据"/>&nbsp;
                    <button onClick={this.showData}>点我提示左侧数据</button>
                    &nbsp;
                    <input ref="input2" type="text" onBlur={this.showDataBlur} placeholder="失去焦点提示数据"/>
                </div>
            )
        }
    }

    ReactDOM.render(<Demo/>, document.getElementById('test'))
</script>
</html>